package com.qd.dict.panda;

import com.cdqidi.dict.annotation.FieldBind;
import com.cdqidi.dict.config.IFieldProcess;
import com.qd.common.dict.DictConstant;
import com.qd.panda.service.commodity.CommodityClassificationService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

/**
 * 系统码表名字转换
 *
 * @author sjk
 */
@Component
@RequiredArgsConstructor
@Lazy
public class CommodityClassificationProcessImpl implements IFieldProcess {
    private final CommodityClassificationService commodityClassificationService;

    @Override
    public String processName() {
        return DictConstant.DC_COMMODITY_CLASSIFICATION;
    }

    @Override
    public Object convertValue(FieldBind fieldBind, Object fieldValue) {
        if (null == fieldValue) {
            return "";
        }
        return commodityClassificationService.idToDisplay(fieldValue.toString());
    }
}